<template>
	<view class="container">
		<Default
			:showflag="showflag"
			:type='4'
		></Default>
		<view class="comment" v-if="commentData" v-for="(item, index) in commentData">
			<!-- 用户头像和评分 -->
			<view class="user_info">
				<view class="avator">
					<image :src="item.user.avatar" mode=""></image>
				</view>
				<view class="user_msg">
					<view class="name">{{ item.user.nickname }}</view>
					<view class="star">
						<!-- 评分组件文档信息：  https://ext.dcloud.net.cn/plugin?id=33 -->
						<uniRate :size="18" :readonly="true" :value="item.score"/>
					</view>
				</view>
			</view>
			<!-- 用户评论 -->
			<view class="user_comment">
				<view>{{ item.content }}</view>
				<view>
					<image v-if="item.image" v-for="(v, n) in item.image" :src="v" mode=""></image>
					<!-- <image src="https://community.chuangxiangdianli.com/images/me/avator.png" mode=""></image>
					<image src="https://community.chuangxiangdianli.com/images/me/avator.png" mode=""></image> -->
				</view>
			</view>
			<!--  商品信息 -->
			<view class="goods">
				<image @click="goDetail" src="https://community.chuangxiangdianli.com/images/me/avator.png" mode=""></image>
				<view class="goodsMsg">
					<view class="goodsName">女装条纹一字领露肩荷叶边中长款经典裙子</view>
					<view class="goodsPrice">￥<text>54.00</text></view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	// import uniRate from '../../../components/uni-rate/uni-rate.vue'
	export default{
		components: {
			// uniRate
		},
		data() {
			return {
				showflag: true,
				commentData: [], // 评论数据
				
			}
		},
		onShow() {
			this.getCommentData()
		},
		methods: {
			// 获取用户所有评论
			getCommentData() {
				let that = this
				that.$mrequest({
					url: 'wechat/getComments',
					method: 'POST',
					callBack: function callBack (res) {
						console.log('用户评论请求成功', res)
						if (res.status) {
							that.commentData = res.data.data
							if (that.commentData.length > 0) {
								that.showflag = false
							} else {
								that.showflag = trur
							}
						}
					},
					fail: function fail (res) {
						console.log('用户评论请求失败', res)
					}
				})
			},
			//  跳转商品详情
			goDetail(id) {
				uni.navigateTo({
					url: '/other/goodsDetail/index?goods_id=' + id
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.container{
		height: 100%;
		background: #fff;
	}
	.comment{
		width: 100%;
		padding: 30rpx 30rpx 16rpx;
		box-sizing: border-box;
		background-color: #fff;
		border-bottom: 13rpx solid #F7F6F9;
		.user_info{
			display: flex;
			flex-direction: row;
			justify-content: flex-start;
			width: 100%;
			.avator{
				height: 70rpx;
				width: 70rpx;
				margin-right: 15rpx;
				&>image{
					display: block;
					height: 70rpx;
					width: 70rpx;
					border-radius: 50%;
				}
			}
			.user_msg{
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #333333;
				.name{
					text-indent: .5rem;
				}
			}
		}
		.user_comment{
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #333333;
			&>view:nth-child(2){
				display: flex;
				flex-direction: row;
				justify-content: flex-start;
				flex-wrap: wrap;
				&>image{
					display: block;
					height: 180rpx;
					width: 180rpx;
					margin: 12rpx;
				}
			}
		}
		.goods{
			display: flex;
			flex-direction: row;
			justify-content: flex-start;
			height: 200rpx;
			width: 100%;
			padding: 42rpx 30rpx 25rpx;
			box-sizing: border-box;
			background-color: #F7F6F9;
			border-radius: 15rpx;
			&>image{
				display: inline-block;
				height: 132rpx;
				width: 127rpx;
				margin-right: 34rpx;
			}
			.goodsMsg{
				font-size: 28rpx;
				font-family: Source Han Sans CN;
				font-weight: 500;
				color: #494949;
				.goodsPrice{
					font-size: 22rpx;
					font-family: Source Han Sans CN;
					font-weight: 500;
					color: #F55519;
					&>text{
						font-size: 30rpx;
					}
				}
			}
		}
	}
</style>
